package hn.cch.grammar.bootstrap;

import java.io.IOException;
import java.util.Scanner;

public class ProcessDemo {

    public static void main(String[] args) throws IOException {
        ProcessBuilder processBuilder = new ProcessBuilder("cmd", "/c", "ipconfig/all");
        Process process = processBuilder.start();
        Scanner scanner = new Scanner(process.getInputStream());
        while (scanner.hasNextLine()) {
            System.out.println(scanner.nextLine());
        }
        scanner.close();
        process.destroy();
    }

    public static void testRuntime() throws IOException {
        // Runtime runtime = Runtime.getRuntime();
        // runtime.exec("notepad");


        // String command = "cmd " + "/c " + "ipconfig/all";
        String command = "ifconfig";
        Process process = Runtime.getRuntime().exec(command);
        process.destroy();
    }

}
